import abp from 'abp'

/**
 * 处理图片样式
 * @param {(string)} url
 * @param {string} styleName
 * @returns {string}
 */
export function imageStyle(url, styleName, styleDelimiter) {
	if (arguments.length === 0) {
		return url
	}
	if (!url) { return url; }
	if (!styleName) { return url; }

	styleDelimiter = styleDelimiter || '-';

	var result = url;

	const blogStoringProvider = (abp.setting.get('app.blog_storing.provider') || "Local").toLowerCase();
	
	if (blogStoringProvider === "local") {
		result = url
	}
	if (blogStoringProvider === "aliyun") {
		if (url.indexOf('?') > -1) {
			result = `${url}&x-oss-process=style/${styleName}`
		} else {
			console.log('2222222222');
			result = `${url}?x-oss-process=style/${styleName}`
		}
	}
	if (blogStoringProvider === "qiniu") {
		result = `${url}${styleDelimiter}${styleName}`
	}

	return result;
}
